//
//  SexTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/11/30.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "SexTableViewCell.h"

NSString *const kSexTableViewCellIdentifier = @"kSexTableViewCellIdentifier";

@implementation SexTableViewCell

+ (instancetype)dequeueReusableWithTableView:(UITableView *)tableView
{
    SexTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kSexTableViewCellIdentifier];
    if (cell == nil)
    {
        cell = [[SexTableViewCell alloc]init];
    }
    return cell;
}

- (instancetype)init
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kSexTableViewCellIdentifier];
    if (self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = cellBackgroundColor;
        [self masLayoutSubview];
    }
    return self;
}


- (UILabel *)titleLabel
{
    if(!_titleLabel)
    {
        UIView *superView = self.contentView;
        _titleLabel = [[UILabel alloc]init];
        [superView addSubview:_titleLabel];
        [_titleLabel setFont:fontCommonSize];
        [_titleLabel setTextColor:[UIColor whiteColor]];
    }
    return _titleLabel;
}


- (UIButton *)selectedButton
{
    if(!_selectedButton)
    {
        UIView *superView = self.contentView;
        _selectedButton = [[UIButton alloc]init];
        [superView addSubview:_selectedButton];
        [_selectedButton setImage:imageWithName(@"but_select_pre") forState:UIControlStateSelected];
        _selectedButton.userInteractionEnabled = NO;
    }
    return _selectedButton;
}




- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    

    
    [self.selectedButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1920Height(40));
        make.width.height.mas_equalTo(px1080Width(80));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).with.offset(px1920Height(40));
        make.right.mas_equalTo(self.selectedButton.mas_left);
        //        make.width.mas_equalTo(px1080Width(200));
    }];
    
    UIView *lineView = ({
        lineView = [[UIView alloc]init];
        [superView addSubview:lineView];
        lineView.backgroundColor = rgba(6,27,56,1);
        [lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(superView.mas_bottom);
            make.left.right.mas_equalTo(superView);
            make.height.mas_equalTo(px1920Height(1));
        }];
        lineView;
        
    });
}

@end
